<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>计划执行-计划调整详情页面</title>
    <script src="/scripts/boot.js"></script>
    <link href="/scripts/daterangepicker/js/daterangepicker.min.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/daterangepicker/js/moment.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/js/jquery.daterangepicker.min.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/ux.daterangepicker.js" type="text/javascript"></script>
    <link href="/scripts/daterangepicker/css/skin.css" rel="stylesheet" type="text/css" />
    <style>
        html body .searchbox .mini-buttonedit-icon
        {
            /*background:url(static/scripts/daterangepicker/search.gif) no-repeat 50% 50%;*/
        }
        .rangeHidden{
            display: none;
        }
    </style>
</head>
<body class="bg-white">
<div id="viewForm">
    <div class="title-info mb-20"><span>基本信息</span></div>
    <table class="table-bg" border="0" cellpadding="1" cellspacing="1" style="width:100%;table-layout:fixed;">
        <colgroup>
            <col width="160px"></col>
            <col width="50%"></col>
            <col width="160px"></col>
            <col width="50%"></col>
        </colgroup>
        <tr>
            <td class="text-titlebg">计划名称</td>
            <td>
                <input name="id" id="id" class="mini-hidden"/>
                <div class="input-div color-66" id="planName"></div>
                <!--<input type="text" name="planName" class="mini-textbox w250" enabled="false" required="true" errorMode="none" onvalidation="onNullValidation" requiredErrorText="请输入"　vtype="maxLength:48"/>-->
            </td>
            <td class="text-titlebg">
                要调整的计划任务
            </td>
            <td>
                <div class="input-div color-66" id="nodeNames"></div>
                <!--<input type="text" name="nodeName" class="mini-textbox w250" enabled="false" required="true" errorMode="none" onvalidation="onNullValidation" requiredErrorText="请输入"　vtype="maxLength:48"/>-->
            </td>
        </tr>

        <tr>
            <td class="text-titlebg">
                计划起止时间
            </td>
            <td>
                <div class="input-div color-66" id="beginDate"></div>
                <!--<input id="date-range1" class="uc-daterangepicker searchbox w250" name="beginDate" enabled="false"/>-->
            </td>
            <td class="text-titlebg" >
                调整类型
            </td>
            <td>
                <div class="input-div color-66" id="adjustTypeValue"></div>
                <!--<select name="adjustType" class="mini-combobox w250" ajaxType="post" url="/dictionary/listValues?name=adjustType" textField="value" valueField="id" errorMode="none" onvalidation="onChoseValidation"  onvaluechanged="view.valuechangedText" required="true" requiredErrorText="请选择"></select>-->
            </td>
        </tr>


        <tr id="rangeText" class="rangeHidden">
            <td class="text-titlebg">
                <span class="color-red"></span>结束时间调整到
            </td>
            <td>
                <div class="input-div color-66" id="delayDate"></div>
                <!--<input id="date-range" class="mini-datepicker searchbox w250" name="delayDate" allowInput="false" showTodayButton="false" ondrawdate="view.onDrawDate" onvaluechanged="view.changeTime"/>-->
            </td>
            <td class="text-titlebg">
                <span class="color-red"></span>调整工期
            </td>
            <td>
                <div class="input-div color-66" id="adjustDeadline"></div>
                <!--<input type="text"  id="adjustDeadline" name="adjustDeadline" enabled="false" class="mini-textbox w250" errorMode="none"/>-->
            </td>
        </tr>
        <tr id="range2Text" class="rangeHidden">
            <td class="text-titlebg">
                <span class="color-red"></span>调整到起止时间
            </td>
            <td>
                <div class="input-div color-66" id="adjustDate"></div>
                <!--<input id="date-range2" class="mini-datepicker searchbox w250" name="endDate" allowInput="false" showTodayButton="false" ondrawdate="view.onDrawDate"/>-->
            </td>
        </tr>
        <tr>
            <td class="text-titlebg noEmpty">申请原因</td>
            <td colspan="3">
                <div class="textarea-div color-66" id="remark"></div>
                <!--<textarea name="remark" class="mini-textarea wtextarea" emptyText=""></textarea>-->
            </td>
        </tr>
    </table>
    <div class="title-info"><span>影响的节点计划</span></div>
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:260px; margin-top: 10px;" url="/planNodeAdjust/affectedListByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="user_id" multiSelect="false">
        <div property="columns">
            <div type="indexcolumn"width="35" headerAlign="center" align="center">编号</div>
            <div field="planName" width="120" headerAlign="center" allowSort="true">计划名称</div>
            <div field="remark" width="120" headerAlign="center" allowSort="true">说明</div>
            <div field="postName" width="120" headerAlign="center" allowSort="true">负责岗位</div>
            <div field="beginDate" width="120" headerAlign="center" allowSort="true">计划起止时间</div>
            <div field="deadlineDesc" width="120" headerAlign="center" allowSort="true">工期说明</div>
        </div>
    </div>
    <div class="mini-fit"></div>
   <div>
		<iframe id="workflowiframe" src=""  frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" width="100%" frameborder="0" height="1050"></iframe>
	</div>
</div>
<script src="/scripts/res/js/common.js"></script>
<script type="text/javascript">

    var post_flag,form,state,datas;
    var view = {
        init: function () {
            post_flag = false; //设置一个对象来控制是否进入AJAX过程
            mini.parse();
            form = new mini.Form("#viewForm");
            mini.get("datagrid1").on("drawcell", function (e) {
                var column = e.column;
                if(column.field=="beginDate"){
                    e.cellHtml = e.row.beginDate.substring(0,10)+'至'+e.row.endDate.substring(0,10);
                }
            }) ;
            if(view.getURLParameter("id")){
            	view.SetData({"id":view.getURLParameter("id"),"planNodeId":view.getURLParameter("planNodeId")});
            }
            if(view.getURLParameter("userId")){
	            var userId=view.getURLParameter("userId");
	        	var token=view.getURLParameter("token");
	        	var taskName=view.getURLParameter("taskName");
	        	var taskId=view.getURLParameter("taskId");
	        	var taskDefKey=view.getURLParameter("taskDefKey");
	        	var procInsId=view.getURLParameter("procInsId");
	        	var procDefId=view.getURLParameter("procDefId");
	        	var status=view.getURLParameter("status");
	        	var id=view.getURLParameter("id");
	        	
	        	$('#workflowiframe').attr('src','http://114.242.165.90:15986/workflow/a/oa/testAudit/form?'+
	        			'act.taskId='+taskId+
	        			'&act.taskName='+taskName+
	        			'&act.taskDefKey='+taskDefKey+
	        			'&act.procInsId='+procInsId+
	        			'&act.procDefId='+procDefId+
	        			'&act.status='+status+
	        			'&id='+id+
	        			'&act.userId='+userId+
	        			'&act.token='+token);
            }
        },

        getURLParameter: function (name) { 
        	return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
        },
        //保存
        save: function () {
            form.validate();
            if (form.isValid() == false) return;
            if (post_flag) return;
            var data = form.getData(true);//获取表单多个控件的数据
            data['planNode.id']=data.id;
            delete data["id"];
            data['adjustType.id']=data.adjustType;
            delete data["adjustType"];

            post_flag = true;
            $.ajax({
                url: ("/planNodeAdjust/save"),
                type: "post",
                data: data,
                success: function (msg) {
                    post_flag = false;
                    common.unmask();
                    CloseWindow("ok");
                },
                error: function (errorMsg) {
                    post_flag = false;
                    common.unmask();
                }
            });
        },
//    数据展示
        SetData: function (data) {
            data = mini.clone(data);
            state = data.state;
            mini.get("datagrid1").load({"id":data.planNodeId});
            mini.get("id").setValue(data.id);
            $.ajax({
                url:"/planNodeAdjust/info?id=" + data.id,
                type: "post",
                success: function (text) {
                    var obj = JSON.parse(text);
                    //跨页面传递的数据对象，克隆后才可以安全使用
                    datas = mini.decode(obj.body[0]);   //反序列化成对象
                    form.setData(datas);             //设置多个控件数据
                    var beDate,adDate;
                    $.each(datas,function(key,value){
                        $("#"+key).html(value);
                        if(key=="beginDate"){
                            beDate=value;
                        }
                        if(key=="endDate"){
                            if(value){
                                beDate=beDate+" 至 "+value;
                            }
                            $("#beginDate").text(beDate);
                        }
                        if(key=="adjustBeginDate"){
                        	adDate=value;
                        }
                        if(key=="adjustEndDate"){
                            if(value){
                            	adDate=adDate+" 至 "+value;
                            }
                            $("#adjustDate").text(adDate);
                        }
                        if(key=="nodeName"){
                            $("#nodeNames").html(value)
                        }
                        if(key=="adjustDeadline"){
                            $("#adjustDeadline").html(value+"天")
                        }
                        if(key=="adjustType"){
                            if(value==226){
                                $("#rangeText").removeClass('rangeHidden');
                                $("#range2Text").addClass('rangeHidden');

                            }else if(value==227){
                                $("#range2Text").removeClass('rangeHidden');
                                $("#rangeText").addClass('rangeHidden');
                            }else{
                                $("#rangeText").addClass('rangeHidden');
                                $("#range2Text").addClass('rangeHidden');
                            }
                        }
                    });
                }
            });
        },
        valuechangedText: function (e) {
            if(e.value==226){
                $("#rangeText").removeClass('rangeHidden');
                $("#range2Text").addClass('rangeHidden');
                mini.get("date-range2").setValue(datas.endDate);
                mini.get("date-range").setValue(datas.endDate);

            }else if(e.value==227){
                mini.get("date-range2").setValue(datas.endDate);
                mini.get("date-range").setValue(datas.endDate);
                mini.get("adjustDeadline").setValue(0);
                $("#range2Text").removeClass('rangeHidden');
                $("#rangeText").addClass('rangeHidden');
            }else{
                mini.get("date-range").setValue("");
                mini.get("date-range2").setValue("");
                mini.get("adjustDeadline").setValue(0);
                $("#rangeText").addClass('rangeHidden');
                $("#range2Text").addClass('rangeHidden');
            }
        },
        onDrawDate: function (e) {
            var date = e.date;
            if (date.getTime() < new Date(datas.endDate).getTime()) {
                e.allowSelect = false;
            }
        },
        changeTime: function (e) {
            var yyyymmdd=e.value.Format("yyyy-MM-dd");
            var adjustDeadline=(new Date(yyyymmdd).getTime()-new Date(datas.endDate).getTime())/(1000*60*60*24);
            mini.get("adjustDeadline").setValue(adjustDeadline);
        }
    };
    view.init();
</script>
</body>
</html>